﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Presenter;
using IView;
using JSKE.DiaryAndTracking;

namespace JSKE
{
    public partial class NLPTaskForm : FormLang, INLPTaskForm
    {
        private PresenterNLPTaskForm _presenter;

        public NLPTaskForm()
        {
            InitializeComponent();
            _presenter = new PresenterNLPTaskForm(this);
        }

        private void btnSendToNLP_Click(object sender, EventArgs e)
        {
            _presenter.parseTask(txtTaskInput.Text.Trim());
        }

        #region INLPTaskForm Members

        public void setTaskParseStatus(string message)
        {
            if (message != "")
            {
                this.txtParseStatus.Text = message;
            }
            else
            {
                this.txtParseStatus.Text = "No message to display";
            }
        }

        public bool getMultiChecked()
        {
            return this.chkMultiTask.Checked;
        }

        public bool getTestCaseChecked()
        {
            return this.chkTestCase.Checked;
        }

        public void displayTask(DataTransferObject.Task result, String taskNotes)
        {            
            if (result.RemainTime > 0)
            {
                this.txtParseStatus.Text = "Parse Task Successfully";
            }
            else
            {
                this.txtParseStatus.Text = "Task that Remainning Time = 0 cannot be scheduled!";
                showMessageBox("One task has zero remaining time");
            }
            TaskForm t = new TaskForm(result, false);

            RichTextBox rtb = new RichTextBox();
            rtb.Text = "JSKE Notes:\n\n" + taskNotes;

            t.SetTaskNotes(rtb.Rtf);
            t.setFocusOnMinSplit(true);
            t.ShowDialog(this);
            this.txtTaskInput.SelectAll();
            this.txtTaskInput.Focus();
            this.txtParseStatus.Text = "Waiting for new Task!";
        }

        public void displayEvent(DataTransferObject.DiaryAndTrackingTask.SupportClassForDiary.JskeEvent eventResult, string eventNotes)
        {
            if (eventResult.EventDuration > 0)
            {
                this.txtParseStatus.Text = "Parse Event Successfully";
            }
            else
            {
                this.txtParseStatus.Text = "This Event has Duration = 0!";
                showMessageBox("One Event has zero Duration");
            }
            List<String> eventType = new List<string>();
            eventType.Add("công việc");
            eventType.Add("chơi bời");
            eventResult.EventType = eventType[0];
            RichTextBox rtb = new RichTextBox();
            rtb.Text = "JSKE Notes:\n\n" + eventNotes;
            eventResult.Notes = rtb.Rtf;
            FrmEditEvent t = new FrmEditEvent(eventResult, eventType);

            
            
            t.ShowDialog(this);
            
            this.txtParseStatus.Text = "Waiting for new Task!";
        }

        public void showMessageBox(String message)
        {
            MessageBox.Show(message, "Notification!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        #endregion

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
